/**
 * Created by yuris on 06.03.15.
 */
package controller {
import feathers.controls.Label;
import feathers.text.BitmapFontTextFormat;

import messages.DebugMessage;

import mvcexpress.mvc.PooledCommand;

import starling.display.DisplayObjectContainer;

import starling.events.EnterFrameEvent;

public class DebugConsoleCommand extends PooledCommand {
    public function execute(params:Object):void {
        switch (params.type){
            case DebugMessage.CONSOLE_SHOW_OBJECT_Z_INDEX:
                DEBUG_showZIndex (params.data);
                break;
        }

    }


    private function DEBUG_showZIndex(displayObject:DisplayObjectContainer):void {
        var DEBUG_zIndexLabel:Label = new Label();
        DEBUG_zIndexLabel.textRendererProperties.useSeparateBatch = false; //use separate if text color will change
        DEBUG_zIndexLabel.textRendererProperties.textFormat = new BitmapFontTextFormat("ComicDB",14)//, 0x333333);//color change causes extra Draw Call
        DEBUG_zIndexLabel.x = -20
        DEBUG_zIndexLabel.y = -100
        DEBUG_zIndexLabel.text = "zIndex";
        displayObject.addChild(DEBUG_zIndexLabel);

        displayObject.addEventListener(EnterFrameEvent.ENTER_FRAME, function(e:EnterFrameEvent):void{
            DEBUG_zIndexLabel.text = "z:"+displayObject.parent.getChildIndex(displayObject);
            // DEBUG_zIndexLabel.x = shelfComponent.view.x - 20;
            // DEBUG_zIndexLabel.y = shelfComponent.view.y - 100;
        });
    }

}
}
